package com.sm42.baseService.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sm42.baseMapper.BaseCrmpMapper;
import com.sm42.baseService.BaseCrmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 1. @Description:
 * 2. @Author: Tombear
 * 3. @Time: 2022/7/15 10:01
 */
@Transactional
public class BaseCrmpServiceImpl<T> implements BaseCrmpService<T> {
    @Autowired
    private BaseCrmpMapper<T> baseCrmpMapper;
    @Override
    public List<T> findAll() {
        return baseCrmpMapper.selectList(null);
    }

    @Override
    public T findById(Long id) {
        return baseCrmpMapper.selectById(id);
    }

    @Override
    public int add(T t) {
        return baseCrmpMapper.insert(t);
    }

    @Override
    public int update(T t) {
        return baseCrmpMapper.updateById(t);
    }

    @Override
    public int deleteById(Long id) {
        return baseCrmpMapper.deleteById(id);
    }

    @Override
    public int batchDeleteByIds(List<Long> ids) {
        return baseCrmpMapper.deleteBatchIds(ids);
    }

    @Override
    public List<T> search(QueryWrapper<T> queryWrapper) {
        return baseCrmpMapper.selectList(queryWrapper);
    }
}
